<?php
/*
 * Created on Feb 23, 2010
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
	$type = $_GET['type'] ? $_GET['type'] : "";	
	$trans = $transactionModel->getTrans(null, null);
	$region = $cityModel->getRegions(null, null);
	$typehouse = $realestateModel->getTypes(null, null);
	$categories = $categoryModel->getCategories(null, null);
	
echo '<div id="main">';
	echo '<div id="col1">';
		echo '<div id="col1_content" class="clearfix" style="font-size: 14px;">';
		
				// Transaction
      			echo '<div id="fu_categories_new_x">';
      			if ($type == 'transaction') {
      				echo '<div class="li_contentx floatboxx" id="allx">';
	      				echo '<div class="cur cur_lvl2">';							
							echo '<a class="cur" onfocus="if(this.blur)this.blur()" href="index.php?type=transaction">';
							echo '<img class="arrow" src="images/clear.gif" width="9" height="5" border="0"/>Sàn giao dịch BĐS</a>';
						echo '</div>';
						echo '<ul class="list_lvl2" id="categoriesContainer">';
						while($row = $transactionModel->getArrayNameTrans($trans)) {
							echo '<li><a href="transaction.php?type=transaction&transactionId='.$row['id'].'" onfocus="if(this.blur)this.blur()" title="'.$row["name"].'" rel="tag" class="statisticx lvl2">';
								echo '<img src="img/hl-otherarticles3li.png" border="0"/>';
								echo '<span class="linkTxt">'.$row['name'].'</span></a>';
							echo '</li>';
						}
						echo '</ul>';
					echo '</div>';
      			} else {
      				echo '<ul class="list_lvl">';
      					echo '<li>';
      						echo '<a href="index.php?type=transaction" onfocus="if(this.blur)this.blur()" title="Management" rel="tag">';
							echo '<img class="arrow" src="images/clear.gif" width="5" height="8" border="0"/>Sàn giao dịch BĐS</a>';
						echo '</li>';
					echo '</ul>';
      			}
      			
      			// City Region
      			if ($type == 'cityregion') {
      				echo '<div class="li_contentx floatboxx" id="allx">';
	      				echo '<div class="cur cur_lvl2">';							
							echo '<a class="cur" onfocus="if(this.blur)this.blur()" href="index.php?type=cityregion">';
							echo '<img class="arrow" src="images/clear.gif" width="9" height="5" border="0"/>Khu đô thị</a>';
						echo '</div>';
						echo '<ul class="list_lvl2" id="categoriesContainer">';
						while($row = $cityModel->getArrayNameRegions($region)) {
							echo '<li><a href="cityregion.php?type=cityregion&cityregionid='.$row['id'].'" onfocus="if(this.blur)this.blur()" title="'.$row['name'].'" rel="tag" class="statisticx lvl2">';
								echo '<img src="img/hl-otherarticles3li.png" border="0"/>';
								echo '<span class="linkTxt">'.$row['name'].'</span></a>';
							echo '</li>';
						}
						echo '</ul>';
					echo '</div>';
      			} else {
      				echo '<ul class="list_lvl">';
      					echo '<li>';
      						echo '<a href="index.php?type=cityregion" onfocus="if(this.blur)this.blur()" title="Management" rel="tag">';
							echo '<img class="arrow" src="images/clear.gif" width="5" height="8" border="0"/>Khu đô thị</a>';
						echo '</li>';
					echo '</ul>';
      			}
      			
      			// Category item list
      			if (count($categories) > 0) {
      				while ($row = $categoryModel->getArrayNameRegions($categories)) {
      					if ($type == 'category'.$row['id']) {
      						echo '<div class="li_contentx floatboxx" id="category">';
      							echo '<div class="cur cur_lvl2">';							
									echo '<a class="cur" onfocus="if(this.blur)this.blur()" href="index.php?type=category'.$row['id'].'">';
									echo '<img class="arrow" src="images/clear.gif" width="9" height="5" border="0"/>'.$row["name"].'</a>';
								echo '</div>';
								echo '<ul class="list_lvl2" id="categoriesContainer">';
								$types = $categoryModel->getTypesByCategoryId($row['id']);
								while($rowDetail = $categoryModel->getArrayNameRegions($types)) {
									echo '<li><a href="typedetail.php?type=category'.$row['id'].'&typeid='.$rowDetail['id'].'" title="Category" class="statisticx lvl2">';
										echo '<img src="img/hl-otherarticles3li.png" border="0"/>';
										echo '<span class="linkTxt">'.$rowDetail['name'].'</span></a>';
									echo '</li>';
								}
								echo '</ul>';
      						echo '</div>';
      					} else {      					
	      					echo '<ul class="list_lvl">';
								echo '<li><a href="index.php?type=category'.$row['id'].'" onfocus="if(this.blur)this.blur()" title="Category item list" rel="tag">';
								echo '<img class="arrow" src="images/clear.gif" width="5" height="8" border="0"/>'.$row["name"].'</a></li>';
							echo '</ul>';
      					}
      				}
      			}
					
					echo '<div class="ul_borderBottom">';
						echo '<img src="images/clear.gif" height="1" width="264" border="0"/>';
					echo '</div>';					
				echo '</div>';
				// end fu_categories_new_x
				
				// begin tin dac biet
				$news = $infoModel->getLastNewItemByContentTypeId(NEWS_ID, MAX_GET_NEWS_ID);				
				
				echo '<div class="widget_background widget_space" style="background:#fff url(\'images/bg_admission.jpg\') bottom no-repeat;">';
					echo '<div class="news"><img src="images/document.png" width="22" height="22" /><h2>Tin mới</h2></div>';
					echo '<div class="widget_margins" style="margin: 0;">';
					while ($new = $infoModel->getArrayNameInfos($news)) {
						echo '<div class="cityRegion"><div style="padding-right:7px; padding-left:7px; padding-bottom:7px;"><p>';
							echo '<h3 class="space-bottom-med" style="font-size: 13px;">';
								echo '<img src="img/icn_blue.gif" /><a href="itemdetail.php?itemdetailid='.$new['id'].'" title="Tin mới nhất" style="padding-left:5px;">'.$new['title'].'</a>';
							echo '</h3>';
							echo '<div style="font-size: 13px;">';
								echo truncate($new['header'], 200).'... ';
								echo '<font color="#AA531A"><a href="itemdetail.php?itemdetailid='.$new['id'].'"> » Chi tiết</a></font>';
							echo '</div>';
						echo '</p></div></div>';	
					}
					echo '</div>'; 
				echo '</div>';
				// end tin dac biet
				
				// begin cp_newest_experts dich vu
				$services = $infoModel->getLastNewItemByContentTypeId(SERVICE_ID, MAX_GET_SERVICE_ID);
				
				echo '<div class="widget_background widget_space" id="cp_newest_experts" style="background:#fff url(\'images/bg_admission.jpg\') bottom no-repeat;">';
					echo '<h3 class="widget_header"><span class="icon-tab">Thông tin dịch vụ</span></h3>';
					while ($service = $infoModel->getArrayNameInfos($services)) {
						echo '<div class="widget_margins cityRegion" style="padding-top: 12px;">';
						echo '<div style="padding-right:7px; padding-left:7px; padding-bottom:5px;">';
							echo '<h3 class="fn url space-bottom-med" style="font-size: 13px;">';
								echo '<img src="img/icn_blue.gif" />';
								echo '<a href="itemdetail.php?itemdetailid='.$service["id"].'" style="padding-left:5px;">'.$service['title'].'</a>';
							echo '</h3>';
							echo '<div style="font-size: 13px;">';
								echo truncate($service['header'], 200).'... ';
								echo '<font color="#AA531A"><a href="itemdetail.php?itemdetailid='.$service['id'].'"> » Chi tiết</a></font>';
							echo '</div>';
						echo '</div></div>';
					}
					include('tygia.inc');
				echo '</div>';

				// Begin my transaction
				if($session->logged_in){
					echo '<div class="widget_background widget_space" id="cp_newest_experts">';	
						echo '<div class="news"><img src="images/chart.png" width="22" height="22" /><h3 class="widget_header" style="float:right;padding-right:152px;padding-top:3px;">Quản lý BĐS</h3></div>';	
						echo '<div class="widget_margins">';
							echo '<div class="li_background">';
								echo '<div class="li_content_tb"  style="padding-left:10px;">';
									echo '<h3 style="padding-bottom:10px;">';
										echo '<a href="addrestate.php"><img src="images/post_pencil.png" width="16px" height="16px" style="margin-right: 3px;" /> Đăng tin</a>';
									echo '</h3>';
									echo '<h3 class="cityRegion" style="padding-top:10px;">';
										echo '<a href="myestate.php"><img src="images/home_pencil.png"  width="16px" height="16px" style="margin-right: 3px;" /> Bất động sản của tôi</a>';
									echo '</h3>';	
								echo '</div>';
							echo '</div>';
						echo '</div>';
					echo '</div>';
				}
				// End my transaction
				
				// begin cp_newest_experts quang cao
				echo '<div class="widget_background widget_space" id="cp_newest_experts">';
					echo '<h3 class="widget_header"><span class="icon-tab">Dành cho quảng cáo</span></h3>';
					echo '<center>';
						echo '<div style="background-color:InfoBackground">';
							$banners = $bannerModel->getBanners();
							while ($row = $bannerModel->getArrayNameRegions($banners)) {
								$fileName = 'img/upload/banner/'.$row["image"];
								if ($row["image"] && file_exists($fileName)) {
									$httpProtocal = (substr($row["url"], 0, 7) == 'http://') ? '' : 'http://';
									echo '<a href="'.$httpProtocal.$row["url"].'" target="_blank" class="link-banner">';
										echo '<img src="'.$fileName.'" width="140px" />';
									echo '</a>';
								}
							}
						echo '</div>';
					echo '</center>';
				echo '</div>';
				// end cp_newest_experts quang cao				
				// begin cp_newest_experts
				echo '<div class="widget_background widget_space" id="cp_newest_experts">';					
					echo '<div class="widget_margins">';
						echo '<div class="li_background">';
							echo '<div class="li_content_tb">';
							echo '<span><img src="img/user-group-icon_2.png" /> Số lượt truy cập: '. (rand(50000, 90000) + $session->num_active_guests) .'</span><br />';
							echo '<span><img src="img/check-user-icon_2.png" /> Số thành viên đang online: '. (rand(50, 2000) + $session->num_active_users) .'</span><p></p>';
							echo '<span><a href="ymsgr:sendIM?hotro_dangtin&m=Chao+ban%2C+toi+muon+hoi+"><img height="26" width="190" src="images/yahoo.jpg" /></a></span><br />';
							echo '<span><a href="skype:phan-minh-trung?chat"><img height="26" width="190" src="images/skype.jpg" /></a></span><br />';
							echo '<img height="26" width="190" src="images/hotline.gif" />';	
							echo '</div>';
						echo '</div>';
						echo '<div>';						
						echo '</div>';
					echo '</div>';
				echo '</div>';
				// end cp_newest_experts
		echo '</div>';
	echo '</div>';
?>
